package com.fortune.rainshinecommon.base;

import java.io.Serializable;
import java.util.List;

import com.fortune.rainshinecommon.enums.ExceptionEnum;
import com.fortune.rainshinecommon.enums.ResultCode;
import com.fortune.rainshinecommon.exceptions.MethodException;

public class MsgModel implements Serializable {

	private static final long serialVersionUID = 4054892350748145972L;

	/**
	 * @Fields msg : 消息
	 */
	private String msg;
	/**
	 * @Fields code : 调用状态 1.成功
	 */
	private int code;
	/**
	 * @Fields data : 返回数据
	 */
	private Object data;

	// 总数量, bootstrapTable是total
	private long count; 


	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public MsgModel() {

	}

	public long getCount() {
		return count;
	}

	public void setCount(long count) {
		this.count = count;
	}

	public MsgModel(ResultCode statusEnum) {
		this.msg = statusEnum.getMessage();
		this.code = statusEnum.getCode();
	}

	public MsgModel(ResultCode statusEnum, Object data) {
		this.msg = statusEnum.getMessage();
		this.code = statusEnum.getCode();
		this.data = data;
	}
	public MsgModel(String msg,ResultCode statusEnum) {
		this.code = statusEnum.getCode();
		this.msg = msg;
	}
	
	public static MethodException throwException(ExceptionEnum exceptionEnum){
		MethodException exceptionJson =new  MethodException(exceptionEnum);
        return exceptionJson;
    }

    public static MethodException throwJson(Integer code, List<String> json){
    	MethodException list =new  MethodException(code,json);
        return list;
    }

	public MsgModel(long count,Object data) {
		super();
		this.code = ResultCode.SUCCESS.getCode();
		this.msg = ResultCode.SUCCESS.getMessage();
		this.data = data;
		this.count = count;
	}   
}
